package cn.yqx.bankshop.goods.config;


import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.session.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;


public class DSLConfiguration  extends Configuration {

    private static final String ES_PATH = "classpath:dslMapper/*.xml";  // 可配置在文件中进行读取

    public DSLConfiguration() {
        super();
        try {
            ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
            Resource[] resource = resolver.getResources(ES_PATH);
            for (Resource rs : resource) {
                new XMLMapperBuilder(rs.getInputStream(), this, resource.toString(), this.getSqlFragments()).parse();
            }
        } catch (Exception e) {
        }
    }
}

